﻿using Business;
using Business.PubInfo;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Detail : System.Web.UI.Page
{
    public string strContent = string.Empty;
    PubInfoManage pimTemp = new PubInfoManage();
    string strJsSrc = string.Empty;
    public string GetTitle()
    {
        string strReturn = Request["lx"];
        return strReturn;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            AppearBiaoTi();
            AddClickCount();//浏览次数
            strread();//内容

        }
    }

    private void AppearBiaoTi()   //显示一、二级导航标题
    {
        DataTable dtReturn = pimTemp.GetBiaoTi(Request["art_id"]);

        if (dtReturn.Rows.Count > 0)
        {
            strclass.Text = dtReturn.Rows[0]["lx"].ToString();
            strsclass.Text = dtReturn.Rows[0]["xlx"].ToString();
        }
        else
        {
            strclass.Text = "暂无栏目";
            strsclass.Text = "暂无栏目";
        }
        ;
    }

    private void strread()  //读取内容
    {
        DataTable dtReturn = pimTemp.GetContent(Request["art_id"]);

        if (dtReturn.Rows.Count > 0)
        {
            lbtitle.Text = dtReturn.Rows[0]["bt"].ToString();

            strContent = dtReturn.Rows[0]["nr"].ToString();
            if (!string.IsNullOrEmpty(strContent))
            {
                strContent = Server.UrlDecode(strContent);
                strContent = strContent.Replace("/ueditor/", "http://" + Request.ServerVariables["Server_Name"] + SystemConfig.NetoWsUrl.Replace("WebFormService.asmx", "") + "JavaScript/ueditor/");

                strJsSrc = "<link rel='stylesheet' type='text/css' href='http://" + Request.ServerVariables["Server_Name"] + SystemConfig.NetoWsUrl.Replace("WebFormService.asmx", "") + "JavaScript/ueditor/third-party/video-js/video-js.min.css' />";

                //strJsSrc += "<script src='http://" + Request.ServerVariables["Server_Name"] + SystemConfig.NetoWsUrl.Replace("WebFormService.asmx", "") + "JavaScript/ueditor/ueditor.parse.min.js'></script>";
                strJsSrc += "<script charset='utf-8' src='http://" + Request.ServerVariables["Server_Name"] + SystemConfig.NetoWsUrl.Replace("WebFormService.asmx", "") + "JavaScript/ueditor/third-party/video-js/video.js'></script>";
                strJsSrc += "<script  charset='utf-8' src='ScriptFile/html5media.min.js'></script>";
            }
            lbfrom.Text = dtReturn.Rows[0]["zz"].ToString();
            lbhit.Text = dtReturn.Rows[0]["hits"].ToString();
            lbdate.Text = dtReturn.Rows[0]["tjrq"].ToString();
        }
        else
        {
            strclass.Text = "暂无栏目";
        }

        if (!string.IsNullOrEmpty(strJsSrc))
        {
            Response.Write(strJsSrc);
        }
    }

    private void AddClickCount()  //浏览次数
    {
        string strUserHostIp = Session["userhostip"] == null ? "" : Session["userhostip"].ToString();

        string strArtId = Request["art_id"];
        if (strUserHostIp != Request.UserHostAddress || Session["RequestId"] != strArtId)
        {
            pimTemp.SetClickCount(strArtId);

            Session["userhostip"] = Request.UserHostAddress;
            Session["RequestId"] = strArtId;
        }
    }
}